from flask import Flask, request, jsonify

app = Flask(__name__)

@app.route('/health', methods=['GET'])
def health():
    return jsonify({"status": "ok"})

@app.route('/analyze', methods=['POST'])
def analyze():
    data = request.get_json()
    code = data.get("code", "")

    # 这里是你们的Transformer模型推理（示例）
    # 你未来可以替换成真正的模型调用逻辑
    # ----------------------------------------------------
    result = {
        "has_vulnerability": True,
        "vulnerability_type": "SQL Injection",
        "confidence": 0.87,
        "location": "Line 15"
    }
    # ----------------------------------------------------

    return jsonify(result)

if __name__ == '__main__':
    app.run(host='127.0.0.1', port=5000)
